package action;

import java.util.List;

import org.apache.struts.action.*;

import dao.TUserDao;
import entity.TUser;

import bean.UserDetailForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UserDetailAction extends Action {

    public ActionForward execute(ActionMapping map, ActionForm frm,
            HttpServletRequest request, HttpServletResponse response) {    
    
        UserDetailForm userFrm = (UserDetailForm)frm;
        String userId = userFrm.getUserId(); 
        
        TUser userDetail = TUserDao.getUserFromId(userId);
        
        // TODO null のときの処理を変更
        if (userDetail != null) {
            request.setAttribute("userDetail", userDetail);
            return map.findForward("success");
        }
        else {
            return map.findForward("error");
        }
        
    }
}
